package com.gitee.free.coding.admin.system.logic;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gitee.free.coding.admin.system.entity.SystemUserAuth;
import com.gitee.free.coding.admin.system.mapper.SystemUserAuthMapper;
import com.gitee.free.coding.core.utils.ReturnVerifier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SystemUserAuthLogic {

    @Autowired
    private SystemUserAuthMapper systemUserAuthMapper;

    /**
     * 根据system_user表中主键查询用户认证信息
     *
     * @param uid system_user表中的主键
     * @return 用户认证信息
     */
    public SystemUserAuth getUserAuthByUserId(Integer uid) {
        QueryWrapper<SystemUserAuth> systemUserAuthQueryWrapper = new QueryWrapper<>();
        systemUserAuthQueryWrapper.eq("uid", uid);
        return systemUserAuthMapper.selectOne(systemUserAuthQueryWrapper);
    }

    /**
     * 添加用户认证信息
     *
     * @param systemUserAuth 用户认证信息
     */
    public void addUserAuth(SystemUserAuth systemUserAuth) {
        int result = systemUserAuthMapper.insert(systemUserAuth);
        ReturnVerifier.verifyInsertOne(result, systemUserAuth);
    }
}
